//
//  UserAccountManager.m
//  HHPLiveVideo
//
//  Created by 韩红坡 on 2017/3/17.
//  Copyright © 2017年 韩红坡. All rights reserved.
//

#import "UserAccountManager.h"

//token
NSString *const kCompanyToken = @"token";//经济公司token
NSString *const kPersonToken = @"personToken";//经纪人token
NSString *const kCompanyLoginSuccess = @"loginSuccess";//经纪人是否登录key
NSString *const kPersonLoginSuccess = @"personLoginSuccess";//经纪人是否登录key
NSString *const kAESKey = @"FPW1pquMOPv0ZWpvkRJQa2rPgSFkpoeS";

@implementation UserAccountManager

#pragma mark Singleton Methods
+ (instancetype)sharedInstance
{
    static dispatch_once_t onceToken = 0;
    __strong static id _shareManager = nil;
    dispatch_once(&onceToken, ^{
        _shareManager = [[self alloc] init];
    });
    return _shareManager;
}

- (id)init
{
    if (self = [super init]) {
        self.loginCompany = [[[NSUserDefaults standardUserDefaults] objectForKey:kCompanyLoginSuccess] boolValue];
        self.loginPerson = [[[NSUserDefaults standardUserDefaults] objectForKey:kPersonLoginSuccess] boolValue];
    }
    return self;
}


- (BOOL)isLoginCompany
{
    if (!_loginCompany) {
        _loginCompany = [UserDefaultsManager boolForKey:kCompanyLoginSuccess];
    }
    
    return _loginCompany;
}


- (BOOL)isLoginPerson
{
    if (!_loginPerson) {
        _loginPerson = [UserDefaultsManager boolForKey:kPersonLoginSuccess];
    }
    
    return _loginPerson;
}

- (void)saveLoginTokenPerson:(NSString *)loginTokenPerson
{
    _loginTokenPerson = loginTokenPerson;
    [UserDefaultsManager setObject:loginTokenPerson forKey:kPersonToken];
}

- (void)saveLoginTokenCompany:(NSString *)loginTokenCompany
{
    _loginTokenCompany = loginTokenCompany;
    [UserDefaultsManager setObject:loginTokenCompany forKey:kCompanyToken];
}

- (NSString *)loginTokenPerson
{
    if (!_loginTokenPerson) {
        _loginTokenPerson = [UserDefaultsManager objectForKey:kPersonToken];
    }
    
    return _loginTokenPerson;
}

- (NSString *)loginTokenCompany
{
    if (!_loginTokenCompany) {
        _loginTokenCompany = [UserDefaultsManager objectForKey:kCompanyToken];
    }
    
    return _loginTokenCompany;
}

@end
